package com.examplemartin.jpademo.bean;


import java.io.Serializable;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AjaxResult  implements Serializable {

  private Integer code;
  private String msg;
  private Map<String, Object> data;

  // 失败
  public static AjaxResult fail(Integer code,String msg){
    AjaxResult result = new AjaxResult();
    result.setCode(code);
    result.setMsg(msg);
    return result;
  }
  // 成功
  public static AjaxResult success(Integer code,String msg,Map data){
    AjaxResult result = new AjaxResult();
    result.setCode(code);
    result.setMsg(msg);
    result.setData(data);
    return result;
  }
}
